<?php
namespace app\admin\controller;
use app\admin\service\UserService;
use think\Request;

class User extends Base
{
    /**
     * 用户列表
    */
    public function index()
    {
        $param = Request::instance()->param();
        // dump($param);die;
        $userService = new UserService;
        $data = $userService->index($param);
        $this->assign('data',$data);
        return $this->fetch();
    }

    /**
     * 用户分类
    */
    public function userType()
    {
        $userService = new UserService;
        $data = $userService->userType();
        $this->assign('data',$data);
        return $this->fetch();
    }

    /**
     * 添加用户分类
    */
    public function addUserType()
    {
        if(Request::instance()->isGet()){
            return $this->fetch();
        }else{
            $post = Request::instance()->post();
            $userService = new UserService;
            return json($userService->addUserType($post));
        }
    }

    /**
     * 编辑用户分类
    */
    public function editUserType()
    {
        $userService = new UserService;
        if(Request::instance()->isGet()){
            $id = input('id/d');
            $data = $userService->editUserTypeGet($id);
            $this->assign('data',$data);
            return $this->fetch();
        }else{
            $post = Request::instance()->post();
            return json($userService->addUserType($post,2));
        }
    }

    /**
     * 删除用户类型
    */
    public function delUserType()
    {
        $id = Request::instance()->post('id');
        $userService = new UserService;
        return json($userService->delUserType($id));
    }

    /**
     * 提现列表
    */
    public function cash()
    {
        $userService = new UserService;
        $param = Request::instance()->param();
        $data = $userService->cash($param);
        $this->assign('data',$data);
        return $this->fetch();
    }

    /**
     * 申请提现
    */
    public function cashExamine()
    {
        if(Request::instance()->post()){
            $userService = new UserService;
            $post = Request::instance()->post();
            return json($userService->cashExamine($post));
        }
    }
}
